home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / ddj0492.zip / DFLT11.ZIP / APPLICAT.C next >
Text File  |  1992-02-29  |  21KB  |  707 lines

  1. /* ------------- applicat.c ------------- */
  2.  
  3. #include "dflat.h"
  4.  
  5. static int ScreenHeight;
  6. static BOOL AltDown = FALSE;
  7.  
  8. extern DBOX Display;
  9. extern DBOX Windows;
  10.  
  11. #ifdef INCLUDE_LOGGING
  12. extern DBOX Log;
  13. #endif
  14.  
  15. #ifdef INCLUDE_SHELLDOS
  16. static void ShellDOS(WINDOW);
  17. #endif
  18. static void CreateMenu(WINDOW);
  19. static void CreateStatusBar(WINDOW);
  20. static void SelectColors(WINDOW);
  21. static void SetScreenHeight(int);
  22. static void SelectLines(WINDOW);
  23.  
  24. #ifdef INCLUDE_WINDOWOPTIONS
  25. static void SelectTexture(void);
  26. static void SelectBorder(WINDOW);
  27. static void SelectTitle(WINDOW);
  28. static void SelectStatusBar(WINDOW);
  29. #endif
  30.  
  31. #ifdef INCLUDE_MULTI_WINDOWS
  32. static void CloseAll(WINDOW, int);
  33. static void MoreWindows(WINDOW);
  34. static void ChooseWindow(WINDOW, int);
  35. static int WindowSel;
  36. static WINDOW oldFocus;
  37. static char *Menus[9] = {
  38.     "~1.                      ",
  39.     "~2.                      ",
  40.     "~3.                      ",
  41.     "~4.                      ",
  42.     "~5.                      ",
  43.     "~6.                      ",
  44.     "~7.                      ",
  45.     "~8.                      ",
  46.     "~9.                      "
  47. };
  48. #endif
  49.  
  50. /* --------------- CREATE_WINDOW Message -------------- */
  51. static int CreateWindowMsg(WINDOW wnd)
  52. {
  53.     int rtn;
  54.     static BOOL DisplayModified = FALSE;
  55.     ScreenHeight = SCREENHEIGHT;
  56.     if (!isVGA() && !DisplayModified)    {
  57.         /* ---- modify Display Dialog Box for EGA, CGA ---- */
  58.         CTLWINDOW *ct, *ct1;
  59.         int i;
  60.         ct = FindCommand(&Display, ID_OK, BUTTON);
  61.         if (isEGA())
  62.             ct1 = FindCommand(&Display,ID_50LINES,RADIOBUTTON);
  63.         else    {
  64.             CTLWINDOW *ct2;
  65.             ct2 = FindCommand(&Display,ID_COLOR,RADIOBUTTON)-1;
  66.             ct2->dwnd.w++;
  67.             for (i = 0; i < 7; i++)
  68.                 (ct2+i)->dwnd.x += 8;
  69.             ct1 = FindCommand(&Display,ID_25LINES,RADIOBUTTON)-1;
  70.         }
  71.         for (i = 0; i < 4; i++)
  72.             *ct1++ = *ct++;
  73.         DisplayModified = TRUE;
  74.     }
  75. #ifdef INCLUDE_WINDOWOPTIONS
  76.     if (cfg.Border)
  77.         SetCheckBox(&Display, ID_BORDER);
  78.     if (cfg.Title)
  79.         SetCheckBox(&Display, ID_TITLE);
  80.     if (cfg.StatusBar)
  81.         SetCheckBox(&Display, ID_STATUSBAR);
  82.     if (cfg.Texture)
  83.         SetCheckBox(&Display, ID_TEXTURE);
  84. #endif
  85.     if (cfg.mono == 1)
  86.         PushRadioButton(&Display, ID_MONO);
  87.     else if (cfg.mono == 2)
  88.         PushRadioButton(&Display, ID_REVERSE);
  89.     else
  90.         PushRadioButton(&Display, ID_COLOR);
  91.     if (cfg.ScreenLines == 25)
  92.         PushRadioButton(&Display, ID_25LINES);
  93.     else if (cfg.ScreenLines == 43)
  94.         PushRadioButton(&Display, ID_43LINES);
  95.     else if (cfg.ScreenLines == 50)
  96.         PushRadioButton(&Display, ID_50LINES);
  97.     if (SCREENHEIGHT != cfg.ScreenLines)    {
  98.         SetScreenHeight(cfg.ScreenLines);
  99.         if (WindowHeight(wnd) == ScreenHeight ||
  100.                 SCREENHEIGHT-1 < GetBottom(wnd))    {
  101.             WindowHeight(wnd) = SCREENHEIGHT-1;
  102.             GetBottom(wnd) = GetTop(wnd)+WindowHeight(wnd)-1;
  103.             wnd->RestoredRC = WindowRect(wnd);
  104.         }
  105.     }
  106.     SelectColors(wnd);
  107. #ifdef INCLUDE_WINDOWOPTIONS
  108.     SelectBorder(wnd);
  109.     SelectTitle(wnd);
  110.     SelectStatusBar(wnd);
  111. #endif
  112.     rtn = BaseWndProc(APPLICATION, wnd, CREATE_WINDOW, 0, 0);
  113.     if (wnd->extension != NULL)
  114.         CreateMenu(wnd);
  115.     CreateStatusBar(wnd);
  116.     LoadHelpFile();
  117.     SendMessage(NULL, SHOW_MOUSE, 0, 0);
  118.     return rtn;
  119. }
  120.  
  121. /* --------- ADDSTATUS Message ---------- */
  122. static void AddStatusMsg(WINDOW wnd, PARAM p1)
  123. {
  124.     if (wnd->StatusBar != NULL)    {
  125.         if (p1 && *(char *)p1)
  126.             SendMessage(wnd->StatusBar, SETTEXT, p1, 0);
  127.         else 
  128.             SendMessage(wnd->StatusBar, CLEARTEXT, 0, 0);
  129.         SendMessage(wnd->StatusBar, PAINT, 0, 0);
  130.     }
  131. }
  132.  
  133. /* -------- SETFOCUS Message -------- */
  134. static void SetFocusMsg(WINDOW wnd, BOOL p1)
  135. {
  136.     if (p1)
  137.         SendMessage(inFocus, SETFOCUS, FALSE, 0);
  138.     /* --- remove window from list --- */
  139.     RemoveFocusWindow(wnd);
  140.     /* --- move window to end/beginning of list --- */
  141.     p1 ? AppendFocusWindow(wnd) : PrependFocusWindow(wnd);
  142.     inFocus = p1 ? wnd : NULL;
  143.     SendMessage(wnd, BORDER, 0, 0);
  144. }
  145.  
  146. /* ------- SIZE Message -------- */
  147. static void SizeMsg(WINDOW wnd, PARAM p1, PARAM p2)
  148. {
  149.     BOOL WasVisible;
  150.     WasVisible = isVisible(wnd);
  151.     if (WasVisible)
  152.         SendMessage(wnd, HIDE_WINDOW, TRUE, 0);
  153.     if (p1-GetLeft(wnd) < 30)
  154.         p1 = GetLeft(wnd) + 30;
  155.     BaseWndProc(APPLICATION, wnd, SIZE, p1, p2);
  156.     CreateMenu(wnd);
  157.     CreateStatusBar(wnd);
  158.     if (WasVisible)
  159.         SendMessage(wnd, SHOW_WINDOW, 0, 0);
  160. }
  161.  
  162. /* ----------- KEYBOARD Message ------------ */
  163. static int KeyboardMsg(WINDOW wnd, PARAM p1, PARAM p2)
  164. {
  165.     AltDown = FALSE;
  166.     if (WindowMoving || WindowSizing || (int) p1 == F1)
  167.         return BaseWndProc(APPLICATION, wnd, KEYBOARD, p1, p2);
  168.     switch ((int) p1)    {
  169.         case ALT_F4:
  170.             PostMessage(wnd, CLOSE_WINDOW, 0, 0);
  171.             return TRUE;
  172. #ifdef INCLUDE_MULTI_WINDOWS
  173.         case ALT_F6:
  174.             SetNextFocus(inFocus);
  175.             SkipSystemWindows(FALSE);
  176.             return TRUE;
  177. #endif
  178.         case ALT_HYPHEN:
  179.             BuildSystemMenu(wnd);
  180.             return TRUE;
  181.         default:
  182.             break;
  183.     }
  184.     PostMessage(wnd->MenuBarWnd, KEYBOARD, p1, p2);
  185.     return TRUE;
  186. }
  187.  
  188. /* --------- SHIFT_CHANGED Message -------- */
  189. static void ShiftChangedMsg(WINDOW wnd, PARAM p1)
  190. {
  191.     if ((int)p1 & ALTKEY)
  192.         AltDown = TRUE;
  193.     else if (AltDown)    {
  194.         AltDown = FALSE;
  195.         if (wnd->MenuBarWnd != inFocus)
  196.             SendMessage(NULL, HIDE_CURSOR, 0, 0);
  197.         SendMessage(wnd->MenuBarWnd, KEYBOARD, F10, 0);
  198.     }
  199. }
  200.  
  201. /* -------- COMMAND Message ------- */
  202. static void CommandMsg(WINDOW wnd, PARAM p1, PARAM p2)
  203. {
  204.     switch ((int)p1)    {
  205.         case ID_HELP:
  206.             DisplayHelp(wnd, DFlatApplication);
  207.             break;
  208.         case ID_HELPHELP:
  209.             DisplayHelp(wnd, "HelpHelp");
  210.             break;
  211.         case ID_EXTHELP:
  212.             DisplayHelp(wnd, "ExtHelp");
  213.             break;
  214.         case ID_KEYSHELP:
  215.             DisplayHelp(wnd, "KeysHelp");
  216.             break;
  217.         case ID_HELPINDEX:
  218.             DisplayHelp(wnd, "HelpIndex");
  219.             break;
  220. #ifdef TESTING_DFLAT
  221.         case ID_LOADHELP:
  222.             LoadHelpFile();
  223.             break;
  224. #endif
  225. #ifdef INCLUDE_LOGGING
  226.         case ID_LOG:
  227.             MessageLog(wnd);
  228.             break;
  229. #endif
  230. #ifdef INCLUDE_SHELLDOS
  231.         case ID_DOS:
  232.             ShellDOS(wnd);
  233.             break;
  234. #endif
  235.         case ID_EXIT:
  236.         case ID_SYSCLOSE:
  237.             PostMessage(wnd, CLOSE_WINDOW, 0, 0);
  238.             break;
  239.         case ID_DISPLAY:
  240.             if (DialogBox(wnd, &Display, TRUE, NULL))    {
  241.                 SendMessage(wnd, HIDE_WINDOW, 0, 0);
  242.                 SelectColors(wnd);
  243.                 SelectLines(wnd);
  244. #ifdef INCLUDE_WINDOWOPTIONS
  245.                 SelectBorder(wnd);
  246.                 SelectTitle(wnd);
  247.                 SelectStatusBar(wnd);
  248.                 SelectTexture();
  249. #endif
  250.                 CreateMenu(wnd);
  251.                 CreateStatusBar(wnd);
  252.                 SendMessage(wnd, SHOW_WINDOW, 0, 0);
  253.             }
  254.             break;
  255.         case ID_SAVEOPTIONS:
  256.             SaveConfig();
  257.             break;
  258. #ifdef INCLUDE_MULTI_WINDOWS
  259.         case ID_WINDOW:
  260.             ChooseWindow(wnd, (int)p2-2);
  261.             break;
  262.         case ID_CLOSEALL:
  263.             CloseAll(wnd, FALSE);
  264.             break;
  265.         case ID_MOREWINDOWS:
  266.             MoreWindows(wnd);
  267.             break;
  268. #endif
  269. #ifdef INCLUDE_RESTORE
  270.         case ID_SYSRESTORE:
  271. #endif
  272.         case ID_SYSMOVE:
  273.         case ID_SYSSIZE:
  274. #ifdef INCLUDE_MINIMIZE
  275.         case ID_SYSMINIMIZE:
  276. #endif
  277. #ifdef INCLUDE_MAXIMIZE
  278.         case ID_SYSMAXIMIZE:
  279. #endif
  280.             BaseWndProc(APPLICATION, wnd, COMMAND, p1, p2);
  281.             break;
  282.         default:
  283.             if (inFocus != wnd->MenuBarWnd && inFocus != wnd)
  284.                 PostMessage(inFocus, COMMAND, p1, p2);
  285.             break;
  286.     }
  287. }
  288.  
  289. /* --------- CLOSE_WINDOW Message -------- */
  290. static int CloseWindowMsg(WINDOW wnd)
  291. {
  292.     int rtn;
  293. #ifdef INCLUDE_MULTI_WINDOWS
  294.     CloseAll(wnd, TRUE);
  295. #endif
  296.     PostMessage(NULL, STOP, 0, 0);
  297.     rtn = BaseWndProc(APPLICATION, wnd, CLOSE_WINDOW, 0, 0);
  298.     if (ScreenHeight != SCREENHEIGHT)
  299.         SetScreenHeight(ScreenHeight);
  300.     UnLoadHelpFile();
  301.     return rtn;
  302. }
  303.  
  304. /* --- APPLICATION Window Class window processing module --- */
  305. int ApplicationProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
  306. {
  307.     switch (msg)    {
  308.         case CREATE_WINDOW:
  309.             return CreateWindowMsg(wnd);
  310.         case HIDE_WINDOW:
  311.             if (wnd == inFocus)
  312.                 inFocus = NULL;
  313.             break;
  314.         case ADDSTATUS:
  315.             AddStatusMsg(wnd, p1);
  316.             return TRUE;
  317.         case SETFOCUS:
  318.             if ((int)p1 == (inFocus != wnd))    {
  319.                 SetFocusMsg(wnd, (BOOL) p1);
  320.                 return TRUE;
  321.             }
  322.             break;
  323.         case SIZE:
  324.             SizeMsg(wnd, p1, p2);
  325.             return TRUE;
  326. #ifdef INCLUDE_MINIMIZE
  327.         case MINIMIZE:
  328.             return TRUE;
  329. #endif
  330.         case KEYBOARD:
  331.             return KeyboardMsg(wnd, p1, p2);
  332.         case SHIFT_CHANGED:
  333.             ShiftChangedMsg(wnd, p1);
  334.             return TRUE;
  335.         case PAINT:
  336.             if (isVisible(wnd))    {
  337. #ifdef INCLUDE_WINDOWOPTIONS
  338.                 int cl = cfg.Texture ? APPLCHAR : ' ';
  339. #else
  340.                 int cl = APPLCHAR;
  341. #endif
  342.                 ClearWindow(wnd, (RECT *)p1, cl);
  343.             }
  344.             return TRUE;
  345.         case COMMAND:
  346.             CommandMsg(wnd, p1, p2);
  347.             return TRUE;
  348.         case CLOSE_WINDOW:
  349.             return CloseWindowMsg(wnd);
  350.         default:
  351.             break;
  352.     }
  353.     return BaseWndProc(APPLICATION, wnd, msg, p1, p2);
  354. }
  355.  
  356. #ifdef INCLUDE_SHELLDOS
  357. static void SwitchCursor(void)
  358. {
  359.     SendMessage(NULL, SAVE_CURSOR, 0, 0);
  360.     SwapCursorStack();
  361.     SendMessage(NULL, RESTORE_CURSOR, 0, 0);
  362. }
  363.  
  364. /* ------- Shell out to DOS ---------- */
  365. static void ShellDOS(WINDOW wnd)
  366. {
  367.     oldFocus = inFocus;
  368.     SendMessage(wnd, HIDE_WINDOW, 0, 0);
  369.     SwitchCursor();
  370.     if (ScreenHeight != SCREENHEIGHT)
  371.         SetScreenHeight(ScreenHeight);
  372.     SendMessage(NULL, HIDE_MOUSE, 0, 0);
  373.     printf("To return to %s, execute the DOS exit command.",
  374.                     DFlatApplication);
  375.     fflush(stdout);
  376.     spawnl(P_WAIT, getenv("COMSPEC"), NULL);
  377.     if (SCREENHEIGHT != cfg.ScreenLines)
  378.         SetScreenHeight(cfg.ScreenLines);
  379.     SwitchCursor();
  380.     SendMessage(wnd, SHOW_WINDOW, 0, 0);
  381.     SendMessage(oldFocus, SETFOCUS, TRUE, 0);
  382.     SendMessage(NULL, SHOW_MOUSE, 0, 0);
  383. }
  384. #endif
  385.  
  386. /* -------- Create the menu bar -------- */
  387. static void CreateMenu(WINDOW wnd)
  388. {
  389.     AddAttribute(wnd, HASMENUBAR);
  390.     if (wnd->MenuBarWnd != NULL)
  391.         SendMessage(wnd->MenuBarWnd, CLOSE_WINDOW, 0, 0);
  392.     wnd->MenuBarWnd = CreateWindow(MENUBAR,
  393.                         NULL,
  394.                         GetClientLeft(wnd),
  395.                         GetClientTop(wnd)-1,
  396.                         1,
  397.                         ClientWidth(wnd),
  398.                         NULL,
  399.                         wnd,
  400.                         NULL,
  401.                         0);
  402.     SendMessage(wnd->MenuBarWnd,BUILDMENU,
  403.         (PARAM)wnd->extension,0);
  404.     AddAttribute(wnd->MenuBarWnd, VISIBLE);
  405. }
  406.  
  407. /* ----------- Create the status bar ------------- */
  408. static void CreateStatusBar(WINDOW wnd)
  409. {
  410.     if (wnd->StatusBar != NULL)    {
  411.         SendMessage(wnd->StatusBar, CLOSE_WINDOW, 0, 0);
  412.         wnd->StatusBar = NULL;
  413.     }
  414.     if (TestAttribute(wnd, HASSTATUSBAR))    {
  415.         wnd->StatusBar = CreateWindow(STATUSBAR,
  416.                             NULL,
  417.                             GetClientLeft(wnd),
  418.                             GetBottom(wnd),
  419.                             1,
  420.                             ClientWidth(wnd),
  421.                             NULL,
  422.                             wnd,
  423.                             NULL,
  424.                             0);
  425.         AddAttribute(wnd->StatusBar, VISIBLE);
  426.     }
  427. }
  428.  
  429. #ifdef INCLUDE_MULTI_WINDOWS
  430. /* -------- return the name of a document window ------- */
  431. static char *WindowName(WINDOW wnd)
  432. {
  433.     if (GetTitle(wnd) == NULL)    {
  434.         if (GetClass(wnd) == DIALOG)
  435.             return ((DBOX *)(wnd->extension))->HelpName;
  436.         else 
  437.             return "Untitled";
  438.     }
  439.     else
  440.         return GetTitle(wnd);
  441. }
  442.  
  443. /* ----------- Prepare the Window menu ------------ */
  444. void PrepWindowMenu(void *w, struct Menu *mnu)
  445. {
  446.     WINDOW wnd = w;
  447.     struct PopDown *p0 = mnu->Selections;
  448.     struct PopDown *pd = mnu->Selections + 2;
  449.     struct PopDown *ca = mnu->Selections + 13;
  450.     int MenuNo = 0;
  451.     WINDOW cwnd;
  452.     mnu->Selection = 0;
  453.     oldFocus = NULL;
  454.     if (GetClass(wnd) != APPLICATION)    {
  455.         int i;
  456.         oldFocus = wnd;
  457.         /* ----- point to the APPLICATION window ----- */
  458.         while (GetClass(wnd) != APPLICATION)
  459.             if ((wnd = GetParent(wnd)) == NULL)
  460.                 return;
  461.         /* ----- get the first 9 document windows ----- */
  462.         for (i = 0; i < wnd->ChildCt && MenuNo < 9; i++)    {
  463.             cwnd = *(wnd->Children + i);
  464.             if (GetClass(cwnd) != MENUBAR &&
  465.                     GetClass(cwnd) != STATUSBAR) {
  466.                 /* --- add the document window to the menu --- */
  467.                 strncpy(Menus[MenuNo]+4, WindowName(cwnd), 20);
  468.                 pd->SelectionTitle = Menus[MenuNo];
  469.                 if (cwnd == oldFocus)    {
  470.                     /* -- mark the current document -- */
  471.                     pd->Attrib |= CHECKED;
  472.                     mnu->Selection = MenuNo+2;
  473.                 }
  474.                 else
  475.                     pd->Attrib &= ~CHECKED;
  476.                 pd++;
  477.                 MenuNo++;
  478.             }
  479.         }
  480.     }
  481.     if (MenuNo)
  482.         p0->SelectionTitle = "~Close all";
  483.     else
  484.         p0->SelectionTitle = NULL;
  485.     if (MenuNo >= 9)    {
  486.         *pd++ = *ca;
  487.         if (mnu->Selection == 0)
  488.             mnu->Selection = 11;
  489.     }
  490.     pd->SelectionTitle = NULL;
  491. }
  492.  
  493. /* window processing module for the More Windows dialog box */
  494. static int WindowPrep(WINDOW wnd,MESSAGE msg,PARAM p1,PARAM p2)
  495. {
  496.     switch (msg)    {
  497.         case INITIATE_DIALOG:    {
  498.             WINDOW wnd1;
  499.             WINDOW cwnd = ControlWindow(&Windows,ID_WINDOWLIST);
  500.             WINDOW pwnd = GetParent(wnd);
  501.             int sel = 0, i;
  502.             if (cwnd == NULL)
  503.                 return FALSE;
  504.             for (i = 0; i < pwnd->ChildCt; i++)    {
  505.                 wnd1 = *(pwnd->Children + i);
  506.                 if (wnd1 != wnd && GetClass(wnd1) != MENUBAR &&
  507.                         GetClass(wnd1) != STATUSBAR)    {
  508.                     if (wnd1 == oldFocus)
  509.                         WindowSel = sel;
  510.                     SendMessage(cwnd, ADDTEXT,
  511.                         (PARAM) WindowName(wnd1), 0);
  512.                     sel++;
  513.                 }
  514.             }
  515.             SendMessage(cwnd, LB_SETSELECTION, WindowSel, 0);
  516.             AddAttribute(cwnd, VSCROLLBAR);
  517.             PostMessage(cwnd, SHOW_WINDOW, 0, 0);
  518.             break;
  519.         }
  520.         case COMMAND:
  521.             switch ((int) p1)    {
  522.                 case ID_OK:
  523.                     if ((int)p2 == 0)
  524.                         WindowSel = SendMessage(
  525.                                     ControlWindow(&Windows,
  526.                                     ID_WINDOWLIST),
  527.                                     LB_CURRENTSELECTION, 0, 0);
  528.                     break;
  529.                 case ID_WINDOWLIST:
  530.                     if ((int) p2 == LB_CHOOSE)
  531.                         SendMessage(wnd, COMMAND, ID_OK, 0);
  532.                     break;
  533.                 default:
  534.                     break;
  535.             }
  536.             break;
  537.         default:
  538.             break;
  539.     }
  540.     return DefaultWndProc(wnd, msg, p1, p2);
  541. }
  542.  
  543. /* ---- the More Windows command on the Window menu ---- */
  544. static void MoreWindows(WINDOW wnd)
  545. {
  546.     if (DialogBox(wnd, &Windows, TRUE, WindowPrep))
  547.         ChooseWindow(wnd, WindowSel);
  548. }
  549.  
  550. /* ----- user chose a window from the Window menu
  551.         or the More Window dialog box ----- */
  552. static void ChooseWindow(WINDOW wnd, int WindowNo)
  553. {
  554.     int i;
  555.     WINDOW cwnd;
  556.     for (i = 0; i < wnd->ChildCt; i++)    {
  557.         cwnd = *(wnd->Children + i);
  558.         if (GetClass(cwnd) != MENUBAR &&
  559.                 GetClass(cwnd) != STATUSBAR)
  560.             if (WindowNo-- == 0)
  561.                 break;
  562.     }
  563.     if (wnd->ChildCt)    {
  564.         SendMessage(cwnd, SETFOCUS, TRUE, 0);
  565.         if (cwnd->condition == ISMINIMIZED)
  566.             SendMessage(cwnd, RESTORE, 0, 0);
  567.     }
  568. }
  569.  
  570. /* ----- Close all document windows ----- */
  571. static void CloseAll(WINDOW wnd, int closing)
  572. {
  573.     WINDOW wnd1;
  574.     int i;
  575.     SendMessage(wnd, SETFOCUS, TRUE, 0);
  576.     for (i = wnd->ChildCt; i > 0; --i)    {
  577.         wnd1 = *(wnd->Children + i - 1);
  578.         if (GetClass(wnd1) != MENUBAR &&
  579.                 GetClass(wnd1) != STATUSBAR)    {
  580.             ClearVisible(wnd1);
  581.             SendMessage(wnd1, CLOSE_WINDOW, 0, 0);
  582.         }
  583.     }
  584.     if (!closing)
  585.         SendMessage(wnd, PAINT, 0, 0);
  586. }
  587.  
  588. #endif    /* #ifdef INCLUDE_MULTI_WINDOWS */
  589.  
  590. static void DoWindowColors(WINDOW wnd)
  591. {
  592.     WINDOW cwnd;
  593.     int i;
  594.     InitWindowColors(wnd);
  595.     for (i = 0; i < wnd->ChildCt; i++)    {
  596.         cwnd = *(wnd->Children + i);
  597.         DoWindowColors(cwnd);
  598.         if (GetClass(cwnd) == TEXT && GetText(cwnd) != NULL)
  599.             SendMessage(cwnd, CLEARTEXT, 0, 0);
  600.     }
  601. }
  602.  
  603. /* ----- set up colors for the application window ------ */
  604. static void SelectColors(WINDOW wnd)
  605. {
  606.     if (RadioButtonSetting(&Display, ID_MONO))
  607.         cfg.mono = 1;
  608.     else if (RadioButtonSetting(&Display, ID_REVERSE))
  609.         cfg.mono = 2;
  610.     else
  611.         cfg.mono = 0;
  612.     if ((ismono() || video_mode == 2) && cfg.mono == 0)
  613.         cfg.mono = 1;
  614.  
  615.     if (cfg.mono == 1)
  616.         memcpy(cfg.clr, bw, sizeof bw);
  617.     else if (cfg.mono == 2)
  618.         memcpy(cfg.clr, reverse, sizeof reverse);
  619.     else
  620.         memcpy(cfg.clr, color, sizeof color);
  621.     DoWindowColors(wnd);
  622. }
  623.  
  624. /* ---- select screen lines ---- */
  625. static void SelectLines(WINDOW wnd)
  626. {
  627.     cfg.ScreenLines = 25;
  628.     if (isEGA() || isVGA())    {
  629.         if (RadioButtonSetting(&Display, ID_43LINES))
  630.             cfg.ScreenLines = 43;
  631.         else if (RadioButtonSetting(&Display, ID_50LINES))
  632.             cfg.ScreenLines = 50;
  633.     }
  634.     if (SCREENHEIGHT != cfg.ScreenLines)    {
  635.         int FullScreen = WindowHeight(wnd) == SCREENHEIGHT;
  636.         SetScreenHeight(cfg.ScreenLines);
  637.         if (FullScreen || SCREENHEIGHT-1 < GetBottom(wnd))
  638.             SendMessage(wnd, SIZE, (PARAM) GetRight(wnd),
  639.                 SCREENHEIGHT-1);
  640.     }
  641. }
  642.  
  643. /* ---- set the screen height in the video hardware ---- */
  644. static void SetScreenHeight(int height)
  645. {
  646.     if (isEGA() || isVGA())    {
  647.         SendMessage(NULL, SAVE_CURSOR, 0, 0);
  648.         switch (height)    {
  649.             case 25:
  650.                 Set25();
  651.                 break;
  652.             case 43:
  653.                 Set43();
  654.                 break;
  655.             case 50:
  656.                 Set50();
  657.                 break;
  658.             default:
  659.                 break;
  660.         }
  661.         SendMessage(NULL, RESTORE_CURSOR, 0, 0);
  662.         SendMessage(NULL, RESET_MOUSE, 0, 0);
  663.         SendMessage(NULL, SHOW_MOUSE, 0, 0);
  664.     }
  665. }
  666.  
  667. #ifdef INCLUDE_WINDOWOPTIONS
  668.  
  669. /* ----- select the screen texture ----- */
  670. static void SelectTexture(void)
  671. {
  672.     cfg.Texture = CheckBoxSetting(&Display, ID_TEXTURE);
  673. }
  674.  
  675. /* -- select whether the application screen has a border -- */
  676. static void SelectBorder(WINDOW wnd)
  677. {
  678.     cfg.Border = CheckBoxSetting(&Display, ID_BORDER);
  679.     if (cfg.Border)
  680.         AddAttribute(wnd, HASBORDER);
  681.     else
  682.         ClearAttribute(wnd, HASBORDER);
  683. }
  684.  
  685. /* select whether the application screen has a status bar */
  686. static void SelectStatusBar(WINDOW wnd)
  687. {
  688.     cfg.StatusBar = CheckBoxSetting(&Display, ID_STATUSBAR);
  689.     if (cfg.StatusBar)
  690.         AddAttribute(wnd, HASSTATUSBAR);
  691.     else
  692.         ClearAttribute(wnd, HASSTATUSBAR);
  693. }
  694.  
  695. /* select whether the application screen has a title bar */
  696. static void SelectTitle(WINDOW wnd)
  697. {
  698.     cfg.Title = CheckBoxSetting(&Display, ID_TITLE);
  699.     if (cfg.Title)
  700.         AddAttribute(wnd, HASTITLEBAR);
  701.     else
  702.         ClearAttribute(wnd, HASTITLEBAR);
  703. }
  704.  
  705. #endif
  706.  
  707.